/**
 * 
 */
package com.jonosoft.photocast.viewer.web.client.ui;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.jonosoft.photocast.viewer.web.client.util.Size;

/**
 * TODO Add description AppToolbar (com.jonosoft.photocast.viewer.web.client.AppToolbar)
 *
 * @author jon
 *
 */
public class AppToolbar extends Composite {
	
	private static final String STYLE_NAME = "app-menubar";
	public static final int HEIGHT = 40;
	
	private final MenuBar menuBar = new MenuBar();
	
	private final AppMenuItem subscribeMenuItem = new AppMenuItem("subscribe", "Subscribe to Photocast", new SubscribeCommand());
	
	public AppToolbar() {
		initWidget(menuBar);
		
		menuBar.setStyleName("app-menubar");
		
		//menuBar.addItem(subscribeMenuItem);
	}
    
    private static class AppMenuItem extends MenuItem {
    	
    	private static final String STYLE_NAME_SUFFIX = "-menuitem";
    	
    	private String name = null;
    	
        public AppMenuItem(String name, String text, MenuBar subMenu) {
	        super(text, subMenu);
	        init(name);
        }
        
        public AppMenuItem(String name, String text, Command cmd) {
	        super(text, cmd);
	        init(name);
        }
        
        private void init(String name) {
	        this.name = name;
	        setStyleName(name + STYLE_NAME_SUFFIX);
        }
    }
    
    private static class SubscribeCommand implements Command {
        private String stuff = null;

		public void execute() {
        	Window.alert("subscribe");
        }
    }

	/**
     * TODO Add method description for resize
     *
     * @param size
     */
    public void resize(Size size) {
    	menuBar.setHeight(size.getCSSHeight());
    }

}
